<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<div class="award_add">
    <p>添加获奖经历</p>

        <table>
            <tr>
                <td>
                    <div class="layui-inline">
                        <label class="layui-form-label"> 获奖名称</label>
                        <div class="layui-input-inline">
                            <input type="text" id="name" class="layui-input" placeholder="填写获奖名称" value="${award.name}">
                        </div>
                    </div>
                </td>
                <td>
                    <div class="layui-inline">
                        <label class="layui-form-label">获奖时间</label>
                        <div class="layui-input-inline">
                            <input type="text" id="awardTime" class="layui-input" placeholder="yyyy-MM-dd"
                                   value="<fmt:formatDate value="${award.awardTime}" pattern="yyyy-MM-dd"/>">
                        </div>
                    </div>
                </td>

            </tr>
        </table>

    <button class="button_save" value="${award.id}" id="button_award_save_${award.id}" onclick="award_save(this.value)">保存并更新</button>
    <button class="button_cancel" id="button_award_cancel">取消</button>
</div>
<script>
    // $("#button_award_save").click(function () {
    function award_save(obj){
        let resumeId = $("#resumeId").val();
        // console.log($("#award_info"))
        let awardId = obj;
        let name = $("#name").val();
        let awardTime = $("#awardTime").val();

        let param = "id=" + awardId + "&name=" + name + "&awardTime=" + awardTime;
        console.log(param);
        $.post('/hire/resume/award/update', param, function (res) {
            if (res.code == '200') {
                $("#award_info").load("/hire/resume/award_info", {id: resumeId});
                $("#award_edit").hide();
                $("#award_info").show();
            } else {
                layer.msg(res.msg);
            }
        })
    }
    // })
    $("#button_award_cancel").click(function () {
        let resumeId = $("#resumeId").val();
        // console.log($("#award_info"))
        $("#award_info").load("/hire/resume/award_info", {id: resumeId});
        $("#award_edit").hide();
        $("#award_info").show();
    })
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //常规用法
        laydate.render({
            elem: '#awardTime'
        });
    });
</script>